﻿Imports TNCDAL
Imports System.Data.Linq
Imports System.Linq


Public Class CVoyageFee
    Dim db As New TanNamChinhDataContext

    Public Function SelectAllRecord() As IQueryable(Of tblVoyageFee)
        Dim voyage = From p In db.tblVoyageFees
                Select p
        Return voyage
    End Function

    Public Function SelectRecordById(ByVal ID_Voyage As Integer, ByVal ID_Fee As Integer) As tblVoyageFee
        Dim voyage = (From p In db.tblVoyageFees
                 Where p.ID_Voyage = ID_Voyage And p.ID_Fee = ID_Fee
                 Select p).Single
        Return voyage
    End Function

    Public Sub Insert(ByVal obj As tblVoyageFee)
        db.tblVoyageFees.InsertOnSubmit(obj)
        db.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblVoyageFee)
        Dim voyage = SelectRecordById(obj.ID_Voyage, obj.ID_Fee)
        voyage.Price = obj.Price
        voyage.ID_Currency = obj.ID_Currency
        db.SubmitChanges()
    End Sub

    Public Sub Delete(ByVal ID_Voyage As Integer)
        Dim voyage = (From p In db.tblVoyageFees
                 Where p.ID_Voyage = ID_Voyage
                 Select p).Single

        db.tblVoyageFees.DeleteOnSubmit(voyage)
        db.SubmitChanges()
    End Sub
End Class
